package com.iwop.moto.utils.http;

import com.iwop.moto.comm.CommUrl;
import com.iwop.moto.utils.api.YunXin.YunXinUtils;
import com.iwop.moto.utils.http.HttpUtils;
import com.iwop.moto.utils.stringUtil.JsonUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.util.ArrayList;
import java.util.List;

/**
 * 短信通道
 * @author huyuangui 2016-07-08
 */
public class SMSUtil {
    private static String web_url="http://occ.iwop.cn/";
    private static String  send_type="0dae000957903fb6af73e41fa074985c";
    /**
     * 单发送
     * http://192.168.1.130:8888/sms/send/code?send_type=0dae000957903fb6af73e41fa074985c&tel=15980913830&templet_id=10001&value1=874524&value2=5&value3=ThankYou
     * url?modelid=&value1=&value2&value3=&keys=sfsdfsdf
     * @param tel 手机号码
     * @param content 内容
     */
    public static String sendContent(String tel,String content){
        String url=web_url+"sms/send/code?send_type="+send_type+"&tel="+tel+"&templet_id=10001&value1="+content+"&value2=5&value3=";
        return HttpUtils.executeGet(url, null);
    }

    /**
     * @功能: 网易云信短信接口
     * @日期: liuwb by 2016-11-9 15:48:03 create
     * @param tel 手机号
     * @param content 验证码
     */
    public static String sendYunXinSms(String tel,String content){
        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        String [] mobiles = new String [1];
        mobiles[0] = tel;
        String [] params = new String[2];
        params[0] = content;
        params[1] = "5";//5分钟
        nvps.add(new BasicNameValuePair("templateid", "3029411"));
        nvps.add(new BasicNameValuePair("mobiles", JsonUtils.toJsonString(mobiles)));
        nvps.add(new BasicNameValuePair("params", JsonUtils.toJsonString(params)));
        String result = YunXinUtils.sendHttpRequest(CommUrl.SENDTEMPATE, nvps);
        return result;
    }

}
